package com.tiancheng.trade.commom.web.feign;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.commom.core.exception.BusinessException;
import com.tiancheng.trade.commom.web.model.request.*;
import com.tiancheng.trade.commom.web.model.response.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Auther: ld
 * @Date: 2024/3/6 14:00
 * @Param ${tags}
 * @Description: 支付中心服务
 */
@FeignClient(value = "trade-payment")
public interface PaymentFeignService {

	/**
	 * 统一下单接口
	 *
	 * @param orderPayDTO
	 * @return
	 */
	@PostMapping(value = "/api/order/unified", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result<UnifiedOrderResVO> unifiedOrder(@RequestBody OrderPayDTO orderPayDTO);

	/**
	 * 零元订单——支付接口
	 *
	 * @param orderPayDTO
	 * @return
	 */
	@PostMapping(value = "/api/order/deductionUnified", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result<UnifiedOrderResVO> deductionUnified(@RequestBody OrderPayDTO orderPayDTO);

	/**
	 * 统一下单接口
	 *
	 * @param orderPayDTO
	 * @return
	 */
	@PostMapping(value = "/api/order/appleInAppPay", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result appleInAppPay(@RequestBody OrderPayDTO orderPayDTO);

	/**
	 * 统一下单接口
	 *
	 * @param orderPayDTO
	 * @return
	 */
	@PostMapping(value = "/api/order/appleInAppPay/v2", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result appleInAppPayV2(@RequestBody OrderPayDTO orderPayDTO);

	/**
	 * 关闭订单
	 *
	 * @param closeOrderDTO
	 * @return
	 */
	@PostMapping(value = "/api/order/close", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result<String> closeOrder(@RequestBody CloseOrderDTO closeOrderDTO);

	/**
	 * 订单退款
	 *
	 * @param refundDTO
	 * @return
	 */
	@PostMapping(value = "/api/order/refund", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result<RefundOrderResVO> refundOrder(@RequestBody RefundDTO refundDTO);

	/**
	 * 零元订单——退款
	 *
	 * @param refundDTO
	 * @return
	 */
	@PostMapping(value = "/api/order/deductionRefund", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result<RefundOrderResVO> deductionRefund(@RequestBody RefundDTO refundDTO);

	/**
	 * 核销订单
	 * @param verificationRequestVO
	 * @return
	 */
	@PostMapping(value = "/api/order/verification", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result<VerificationOrderResponseVO> verification(@RequestBody VerificationRequestVO verificationRequestVO);

	/**
	 * 核销订单
	 * @param verificationRequestVO
	 * @return
	 */
	@PostMapping(value = "/api/order/refundVerification", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result<VerificationOrderResponseVO> refundVerification(@RequestBody RefundVerificationRequestVO verificationRequestVO);

	/**
	 * 获取渠道的支付方式
	 *
	 * @param payWayQueryRequest 查询参数
	 * @return
	 */
	@PostMapping(value = "/api/paymentWay/getByChannelCode")
	Result<List<PaymentPayWayQueryResponse>> getPayWay(@RequestBody PaymentPayWayQueryRequest payWayQueryRequest);

	/**
	 * 获取当前支付场景支持的支付方式列表
	 *
	 * @param payWayListQueryReq 查询参数
	 * @return
	 */
	@PostMapping(value = "/api/paymentWay/getByPaySceneChannelId")
	Result<List<PaymentPayWayQueryResponse>> getPayWayByPaySceneChannelId(@RequestBody PayWayListQueryReq payWayListQueryReq);


	/**
	 * 获取渠道
	 *
	 * @param channelCode
	 * @return
	 */
	@GetMapping(value = "/api/paymentChannel/getByChannelCode")
	Result getByChannelCode(@RequestParam("channel_code") String channelCode);

	/**
	 * 查询退款订单
	 * todo 支付中心暂缺该接口
	 *
	 * @param
	 * @return
	 */
	@GetMapping(value = "/api/order/queryRefund", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result queryRefund(@RequestParam("user_id") String userId, @RequestParam("flow_id") String refundId);


	/**
	 * 二维码支付统一下单接口
	 *
	 * @param qrcPayDTO 二维码支付参数
	 * @return
	 */
	@PostMapping(value = "/api/qrc/unified", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result qrcUnifiedOrder(@RequestBody QrcPayDTO qrcPayDTO);

	/**
	 * 二维码支付统一下单接口
	 *
	 * @param qrcQueryDTO 二维码支付查询参数
	 * @return
	 */
	@PostMapping(value = "/api/qrc/queryPayResult", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result qrcQueryOrder(@RequestBody QrcQueryDTO qrcQueryDTO);


	/**
	 * 二维码支付统一关闭接口-根据订单号
	 *
	 * @param closeQrOrderDTO 二维码支付-关闭订单参数
	 * @return
	 */
	@PostMapping(value = "/api/qrc/closeByOrderId", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result qrcCloseByOrderId(@RequestBody CloseQrOrderDTO closeQrOrderDTO);



    /**
     * paypal支付创建接口
     *
     * @param paypalCreateDTO
     * @return
     */
    @PostMapping(value = "/api/paypal/creatPay", consumes = MediaType.APPLICATION_JSON_VALUE)
	Result<UnifiedOrderResVO> paypalCreate(@RequestBody PaypalCreateDTO paypalCreateDTO);

    /**
     * paypal支付确认接口
     *
     * @param paypalExecuteDTO
     * @return
     */
    @PostMapping(value = "/api/paypal/executePay", consumes = MediaType.APPLICATION_JSON_VALUE)
    Result paypalExecute(@RequestBody PaypalExecuteDTO paypalExecuteDTO);

    /**
     * paypal支付关闭订单
     *
     * @param closeOrderDTO
     * @return
     */
    @PostMapping(value = "/api/paypal/closeOrder", consumes = MediaType.APPLICATION_JSON_VALUE)
    Result closeIntOrder(@RequestBody CloseOrderDTO closeOrderDTO);

    /**
     * paypal支付订单退款
     *
     * @param intRefundDTO
     * @return
     */
    @PostMapping(value = "/api/paypal/paypalRefund", consumes = MediaType.APPLICATION_JSON_VALUE)
    Result refundIntOrder(@RequestBody IntRefundDTO intRefundDTO);

    /**
     * paypal支付订单查询
     *
     * @param
     * @return
     */
    @GetMapping(value = "/api/paypal/getPaypalInfo", consumes = MediaType.APPLICATION_JSON_VALUE)
    Result getPaypalInfo(@RequestParam("payment_id") String paymentId);

	@GetMapping("/api/order/findFlowDetail")
	Result<?> findFlowDetail(@RequestParam("merchant_code") String merchantCode,
							 @RequestParam("pay_status") String payStatus,
							 @RequestParam("pay_status") String paymentWay,
							 @RequestParam("flow_time_begin") String flowTimeBegin,
							 @RequestParam("flow_time_end") String flowTimeEnd,
							 @RequestParam("current") int current,
							 @RequestParam("size") int size) throws BusinessException;

	@PostMapping("/api/order/unified")
	Result<?> unified(@RequestBody OrderDTO orderDTO) throws BusinessException;

	/**
	 * 查询支付中心的所有支付渠道信息
	 *
	 * @return {@link Result<List>}
	 */
	@GetMapping(value = "/api/paymentChannel/getAll")
	Result<List<PaymentChannelResponseDTO>> getAllChannel();

	@GetMapping(value = "/api/order/querySlottingRate")
	Result querySlottingRate(@RequestParam("flow_id") String flowId, @RequestParam("transaction_type") String transactionType);

}
